﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pahan.McuFusion.Common
{
    public abstract class BuilderBase<T> : IBuilder<T>
    {
        public T Build()
        {
            T instance = CreateInstance();
            Populate(instance);
            return instance;
        }

        protected virtual void Populate(T instance)
        {
        }

        protected virtual T CreateInstance()
        {
            return (T)Activator.CreateInstance(typeof(T), true);
        }
    }
}
